package com.chapter.sample.toolkit.exception;


import com.chapter.sample.toolkit.helper.ExceptionHelper;

/**
 * 阻塞异常，用于限流组件发生限流时
 *
 * @author zlikun
 * @created 2022/1/22 13:24
 */
public class BlockingException extends RuntimeException {

    public BlockingException() {
    }

    public BlockingException(String message) {
        super(message);
    }

    /**
     * 判断给定异常是否是阻塞异常
     *
     * @param throwable 非空
     * @return
     */
    public static boolean isBlockingException(Throwable throwable) {
        if (null == throwable) {
            return false;
        }

        return ExceptionHelper.unwrap(throwable) instanceof BlockingException;
    }
}
